package com.dd.common.dto.system.log;

import com.dd.common.validator.annotation.ValidTimeRange;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.springframework.http.HttpMethod;

import javax.validation.constraints.PastOrPresent;
import java.time.LocalDateTime;

/**
 * @author cheng
 */
@ValidTimeRange(start = "createdAtStart", end = "createdAtEnd")
@Schema(description = "系统操作日志查询DTO")
@Data
public class SysOperateLogQueryDTO implements java.io.Serializable {
    @Schema(description = "操作标题", example = "用户管理-新增")
    private String title;
    @Schema(description = "业务操作类型：1-新增、2-编辑、3-删除、4-导入、5-导出、6-登录、7-其他", example = "1")
    private Integer businessType;
    @Schema(description = "请求方法名", example = "com.dd.admin.controller.system.SysUserController.add")
    private String method;

    /**
     * 之所以设为 HttpMethod 枚举类型，是因为 SpringBoot 会自动转换类型，转换的同时会启动参数验证
     */
    @Schema(description = "http 请求方式，必须是大写", example = "POST")
    private HttpMethod requestMethod;
    @Schema(description = "操作人员类别：1-后台用户、2-前台用户、3-其他", example = "1")
    private String operatorType;
    @Schema(description = "操作人员ID", example = "1")
    private Long userId;
    @Schema(description = "操作人员名称", example = "admin")
    private String userName;

    @Schema(description = "操作IP", example = "127.0.0.1")
    private String ip;

    @Schema(description = "请求地址path", example = "/sys/user/add")
    private String url;

    @Schema(description = "操作状态：1-成功、0-失败", example = "1")
    @Range(min = 0, max = 1, message = "状态值只能是0或1")
    private Integer status;

    @PastOrPresent(message = "开始时间不能是未来时间")
    @Schema(description = "创建时间开始", type = "string", format = "date-time", example = "2024-01-01T00:00:00")
    private LocalDateTime createdAtStart;

    @Schema(description = "创建时间结束", type = "string", format = "date-time", example = "2024-12-31T23:59:59")
    private LocalDateTime createdAtEnd;
}
